﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace robotics_ex_1_3
{
    class Room
    {
        private Polygon _polygon;

        public Room(Polygon polygon)
        {
            _polygon = polygon;
        }

        public List<Point> calcFreeSpace(Polygon robot)
        {
            List<Point> freeSpacePolygonPoints = new List<Point>();

            foreach (Line currentEdge in _polygon.Edges)
            {
                Line innerLine = getInnerLine(currentEdge, robot);
            }

            return freeSpacePolygonPoints;
        }

        private Line getInnerLine(Line edge, Polygon robot)
        {
            Point meetingPoint = robot.getFirstMeetingPoint(edge);

            Int32 xMovement = _polygon.RefPoint.X - meetingPoint.X;
            Int32 yMovement = _polygon.RefPoint.Y - meetingPoint.Y;

            return new Line(new Point(edge.StartPoint.X + xMovement, edge.StartPoint.Y + yMovement),
                            new Point(edge.EndPoint.X + xMovement, edge.EndPoint.Y + yMovement));
        }
    }
}
